<form name="frmSearch" action="" method="GET">
    <table class="list">
        <tr>
            <td>Tên menu</td>
            <td><input type="text" value="<?php if(isset($search['tenmenu'])) echo $search['tenmenu']; ?>" name="tenmenu" style="width:200px"/></td>
            <td>Ngày tạo</td>
            <td>
                Từ ngày: <input type="text" id="fromdate" value="<?php if(isset($search['tungay'])) echo $search['tungay']; ?>" name="tungay" style="width:100px"/>&nbsp;
                Đến ngày: <input type="text" id="todate" value="<?php if(isset($search['denngay'])) echo $search['denngay']; ?>" name="denngay" style="width:100px"/>
            </td>
            <td>Trạng thái</td>
            <td>
                <select name="trangthai" id="trangthai" style="width: 80px;">
                    <option value="tatca" >-- Tất cả --</option>
                    <option value="hoatdong" <?php if( isset($search['trangthai'])) if($search['trangthai'] == 'hoatdong' ) echo "selected";?>>Hiển thị</option>
                    <option value="vohieu"  <?php if( isset($search['trangthai'])) if($search['trangthai'] == 'vohieu' ) echo "selected";?>>Ẩn</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="6" style="padding-top: 10px">
                <input type="submit" name="submit" value="Tìm kiếm" style="width:100px;height:20px"/>
            </td>
        </tr>
    </table>
</form>
<form name="frmSearch" action="/admin/menus/xoa" method="POST">
<?php echo $this->element('message'); ?>
<div class="cat_product cat_endpage">
    <div class="feature">
        <a href="/admin/menus/them" class="button" style="margin-right:5px;">Thêm</a>
        <input type="submit" class="button" value="Xóa"/>
        <div style="text-align:right;margin-top: 5px"><?php echo $this->element('paging'); ?></div>
    </div>
    <table class="list">
        <tr>
            <th><input type="checkbox" style="width:10px;" id="select_all"></th>
            <th>ID</th>
            <th>Tên menu</th>
            <th>Url</th>
            <th>Thứ tự</th>
            <th>Ngày tạo</th>
            <th>Người tạo</th>
            <th>Ngày sửa</th>
            <th>Người sửa</th>
            <th>Trạng thái</th>
            <th>Tùy chọn</th>
        </tr>
        <?php
            if(isset($datas)){
                foreach($datas as $data){
        ?>
        <tr>
            <td><input type="checkbox" value="<?php echo $data['Menu']['id']; ?>" style="width:10px;" name="selected[]"></td>
            <td><?php echo $data['Menu']['id']; ?></td>
            <td><?php echo $data['Menu']['tenmenu']; ?></td>
            <td><?php echo $data['Menu']['url']; ?></td>
            <td><?php echo $data['Menu']['rank']; ?></td>
            <td><?php echo date("d/m/Y", strtotime($data['Menu']['ngaytao'])); ?></td>
            <td><?php echo $data['Nguoitao']['tendangnhap']; ?></td>
            <td><?php echo date("d/m/Y", strtotime($data['Menu']['ngaysua'])); ?></td>
            <td><?php echo $data['Nguoisua']['tendangnhap']; ?></td>
            <td><?php echo '<p><a class="ajax" href="/admin/menus/trangthai/'.$data['Menu']['id'].'" >'.$status[$data['Menu']['trangthai']].'</a></p>'; ?></td>
            <td><a href="/admin/menus/xem/<?php echo $data['Menu']['id']; ?>" class="view" alt="View">Xem</a> | <a href="/admin/menus/sua/<?php echo $data['Menu']['id']; ?>" class="edit" alt="Edit">Sửa</a></td>
        </tr>
         <?php
        }}?>
    </table>
    <div class="page_item">
        <div class="kq_all">Có tổng cộng <strong><?php echo $total; ?></strong> kết quả</div>
    </div>
    <div class="clear"></div>
</div>
<div style="text-align:right;margin-top: 5px; margin-bottom:9px;">
    <?php echo $this->element('paging'); ?>
</div>
</form>
<script>
$('#select_all').change(function() {
    var checkboxes = $(this).closest('form').find(':checkbox');
    if($(this).is(':checked')) {
        checkboxes.attr('checked', 'checked');
    } else {
        checkboxes.removeAttr('checked');
    }
});
$(function() {
    $( "#fromdate" ).datepicker({
        dateFormat: 'dd/mm/yy'
      });
    $( "#todate" ).datepicker({
        dateFormat: 'dd/mm/yy'
      });
});

$(document).ready(function(){
    $(".ajax").colorbox({
        overlayClose: false
    });
});
</script>